22. Exercise: Code a Custom Layout

Code a Custom Layout

In this exercise, you'll create a unique layout resource for tablets. Creating a new layout for larger screen sizes is a good way to make sure that your app looks great across different devices and it is an important part of responsive design.

Exercise Code

Exercise: T12.03-Exercise-TabletLayout

Create a custom layout by following the steps below:

SOLUTION:
  • In your resources directory, create a new layout folder for tablets using a smallest width qualifier (sw600dp for tablets)
  • Copy over the responsive_activity xml to this folder (needs to have the same name as in the base layout folder)
  • Change that xml so that the image appears to the left of the text.
  • Also, add more padding (8dp) to left and right of the linear layout that holds the article text to space it from the ImageView